package com.smartcommunity.entity.people.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import static org.apache.commons.lang3.StringUtils.length;

import java.io.Serializable;

import com.smartcommunity.base.common.CacheMap;
import com.smartcommunity.bean.entity.Village;

/**
 * @ClassName: House
 * @Description: 房屋信息实体类
 * @author: zdy
 * @Date: 2019/1/3 11:07
 * @Company:
 * @version V1.5.0
 */
@Data
@ApiModel
public class HouseDto implements Serializable {
    private static final long serialVersionUID = -1L;
    /**
     *小区编号
     */
    @ApiModelProperty(value="小区编码,多小区以逗号分隔",name="villageCode",example = "123456")
    private String villageCode;
    /**
     *楼栋编号，单元编号示例：28栋2单元，编码为：28-2
     */
    @ApiModelProperty(value="楼栋编号，单元编号示例：28栋2单元，编码为：28-2",name="buildingNo",example = "28-2")
    private String buildingNo;
    /**
     *房屋编号
     */
    @ApiModelProperty(value="房屋编号",name="houseNo",example = "101")
    private String houseNo;
    /**
     * 关联的证件号码
     */
    @ApiModelProperty(value="关联的证件号码",name="credentialNo",example = "420624199909093332")
    private String credentialNo;
    
    @ApiModelProperty(value="单元号",name="unitNo",example = "一单元")
    private String unitNo;
    
    public String concatDetailAddress() {
    	Village village = CacheMap.VILLAGE_INFO_MAP.get(this.getVillageCode());
    	StringBuffer detailAddress = new StringBuffer();
        if (null != village) {
            String villageName = village.getVillageName();
            String buildingNo = this.getBuildingNo();
            String unitNo = this.getUnitNo();
            String houseNo = this.getHouseNo();
            if(length(villageName)>0) {
            	detailAddress.append(villageName);
            }
            if(length(buildingNo)>0) {
            	detailAddress.append(buildingNo).append("栋");
            }
            if(length(unitNo)>0) {
            	detailAddress.append(unitNo).append("单元");
            }
            if(length(houseNo)>0) {
            	detailAddress.append(houseNo).append("室");
            }
        }
        return detailAddress.toString();
    }
    
}
